<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class CommonController extends Controller
{
    public function timeline(){
        list($limit,$skip) = paginate(rq('page'),rq('limit'));
//        dd($limit);
//        dd($skip);
        $questions = question_ins()
            ->with('user')
            ->limit($limit)
            ->skip($skip)
            ->orderBy('created_at','desc')
            ->get();


        $answers = answers_ins()
            ->with('user')
            ->with('user_answer')
            ->limit($limit)
            ->skip($skip)
            ->orderBy('created_at','desc')
            ->get();
//
//        $data = $questions->merge($answers);
//
//        $data = $data->sortByDesc(function ($item){
//            return $item->created_at;
//        });
//        $data  = $data->values()->all();
        return suc('success',$questions);
    }
}
